[2/3] Add CMake build system; remove obsolete build configurations#281
[2/3] Add CMake build system; remove obsolete build configurations#281irodushka merged 3 commits intoFirebirdSQL:masterfrom
Conversation
- Add root CMakeLists.txt that builds the FirebirdODBC.dll driver
- Add IscDbc/CMakeLists.txt for the IscDbc static library
- Add cmake/ helper modules:
- FetchFirebirdHeaders.cmake: downloads Firebird 5.0.2 headers from GitHub
- GetVersionFromGit.cmake: extracts version from git tags
- Version.h.in: template for generated version header
- Update tests/CMakeLists.txt to integrate with root CMake project
(uses FetchContent for Google Test instead of find_package)
- Remove 14 obsolete build configurations (keep MsVc2022.win):
Bcc55.win, CC.solaris, Gcc.darwin, Gcc.freeBSD, Gcc.lin, Gcc.solaris,
MinGW_Dev-Cpp.win, MsSDK64.win, MsVc60.win, MsVc70.win, MsVc80.win,
MsVc90.win, VAC.aix, aCC.HP
- Remove shared makefile includes (makefile.environ, makefile.sources)
- Remove root and IscDbc makefile.in (autotools era)
- Remove vendored Firebird headers (FBClient.Headers/)
— now fetched at build time via CMake FetchContent
- Remove vendored ODBC SDK headers (Headers/SQL.H, Headers/SQLEXT.H)
— use system SDK instead
- Move Headers/OdbcUserEvents.h to project root
- Update OdbcConnection.h include path accordingly
- Remove non-functional old test projects: JdbcTest/, Test/, TestInstall/
- Remove tracked build artifacts (.exp files) and MinGW .def files
- Rename OdbcJdbc.dll.manifest to FirebirdODBC.dll.manifest
(matches the reference in OdbcJdbc.rc)
- Update MsVc2022.win/OdbcFb.vcxproj:
- Include path: FBClient.Headers -> build/_deps/firebird_headers-src/src/include
- Header reference: Headers/OdbcUserEvents.h -> OdbcUserEvents.h
(Requires running 'cmake -B build' first to fetch Firebird headers)
- Update .gitignore with CMake build artifact patterns
Build validation:
CMake: cmake -B build -G 'Visual Studio 17 2022' -A x64
cmake --build build --config Release
-> FirebirdODBC.dll (120 exports, matching VS 2022 build)
VS 2022: MSBuild Builds/MsVc2022.win/OdbcFb.sln /p:Configuration=Release /p:Platform=x64
-> FirebirdODBC.dll (120 exports)
Tests: 375 tests, 375 skipped (no database), 0 failures
|
Hi @fdcastel Have you ever tested this PR on Linux?.. |
DOH! 🤦🏻♂️ No! I only ran them on my (Windows) machine, sorry. 😞 I rely on GitHub Actions for the Linux build and tests (those are coming in the third PR, the next one). I’ll work on the next PR, basing it on this one, so I can verify that everything works across all platforms. |
|
So it shouldn't surprise you that the Linux build is not working) |
Definitely not 🤣. I’ll take care of this over the weekend. Please hold. |
|
Aha) Your PR lacks many features that exist in my one. I'm not speaking about an ugly |
I dropped everything aiming to keep it simpler. But -- of course -- this is just the initial concept and may change. The idea here was to get initial feedbacks. I had no idea what you really want to keep from the legacy code. 😉 Please point here in the code review what you’d like to retain from the previous sources, and I’ll backport it. 👍🏻 |
|
P.s.: Great feedback so far, thanks! Please keep it coming!!! Share anything you’re not happy with here, and I’ll address it in an updated version of this PR over the next few days. |
|
+++ maybe is makes sense to move all the source code to /src folder. It's a kind of standard approach. And just put |
The major things I meant are:
|
- Fix OdbcJdbcSetup sources: Windows uses full GUI setup (17 files), Linux uses only OdbcInstGetProp.cpp (matching makefile.sources) - Exclude ResourceManagerSink.cpp and TransactionResourceAsync.cpp from Linux build (ATL-only) - Add -D_REENTRANT -D_PTHREADS -DEXTERNAL -DunixODBC for Linux (matching old makefile.linux compile flags) - Fix ODBC linking on Linux: use ODBC::ODBC target instead of empty ODBC_LIBRARIES variable - Change IscDbc from STATIC to OBJECT library (avoids unnecessary intermediate archive; objects consumed directly by OdbcFb) - Add CMAKE_BUILD_TYPE defaulting to Release (single-config generators) - Add per-config compiler optimization flags for GCC/Clang (Debug: -O0 -g3, Release: -O3 -ftree-loop-vectorize, etc.) - Add CPU architecture detection (x86, x86_64, ARM64, generic) with -msse4.1 for x86/x86_64 (from PR FirebirdSQL#248) CI workflow updates: - linux.yml: use CMake instead of deleted Gcc.lin makefiles - msbuild.yml: add cmake -B build step to fetch Firebird headers (required by updated .vcxproj include paths) - rpi_arm64.yml: use CMake instead of deleted Gcc.lin makefiles - All workflows: trigger on new-build-system branches + PRs
I FULLY agree. That would be cleaner. But let’s hold off on that for now. I implemented it in v4, so we’ll get there soon. |
Missing features from PR #248a. CMAKE_BUILD_TYPE processing, setting Release as defaultFixed. Added: if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel)
endif()b. Explicit compiler options for different build typesFixed. Added per-config optimization flags for GCC/Clang: add_compile_options(
"$<$<CONFIG:Debug>:-O0;-g3;-D_DEBUG;-DDEBUG;-DLOGGING;-fexceptions>"
"$<$<CONFIG:Release>:-O3;-DNDEBUG;-ftree-loop-vectorize>"
"$<$<CONFIG:RelWithDebInfo>:-O2;-g;-DNDEBUG>"
"$<$<CONFIG:MinSizeRel>:-Os;-DNDEBUG>"
)c. CPU arch detection and -msse4.1 flagFixed. Added architecture detection (x86, x86_64, ARM64, generic) and set(FBODBC_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
if(FBODBC_ARCH STREQUAL "x86" OR FBODBC_ARCH STREQUAL "i686")
add_definitions(-DFBODBC_ARCH_X86)
elseif(FBODBC_ARCH STREQUAL "x86_64" OR FBODBC_ARCH STREQUAL "AMD64")
add_definitions(-DFBODBC_ARCH_X86_64)
elseif(FBODBC_ARCH STREQUAL "aarch64" OR FBODBC_ARCH STREQUAL "arm64" OR FBODBC_ARCH STREQUAL "ARM64")
add_definitions(-DFBODBC_ARCH_ARM64)
else()
add_definitions(-DFBODBC_ARCH_GENERIC)
endif()
if(FBODBC_ARCH_X86 OR FBODBC_ARCH_X86_64)
add_compile_options(-msse4.1)
endif()d. Target for static lib buildNot included in this PR. Can be added as an option if there's demand: option(BUILD_STATIC_LIB "Also build a static library" OFF)Let me know if you'd like this in the current PR or a future one. |
Fix Linux build; address PR FirebirdSQL#281 review feedback - Fix OdbcJdbcSetup sources: Windows uses full GUI setup (17 files), Linux uses only OdbcInstGetProp.cpp (matching makefile.sources) - Exclude ResourceManagerSink.cpp and TransactionResourceAsync.cpp from Linux build (ATL-only) - Add -D_REENTRANT -D_PTHREADS -DEXTERNAL -DunixODBC for Linux (matching old makefile.linux compile flags) - Fix ODBC linking on Linux: use ODBC::ODBC target instead of empty ODBC_LIBRARIES variable - Change IscDbc from STATIC to OBJECT library (avoids unnecessary intermediate archive; objects consumed directly by OdbcFb) - Add CMAKE_BUILD_TYPE defaulting to Release (single-config generators) - Add per-config compiler optimization flags for GCC/Clang (Debug: -O0 -g3, Release: -O3 -ftree-loop-vectorize, etc.) - Add CPU architecture detection (x86, x86_64, ARM64, generic) with -msse4.1 for x86/x86_64 (from PR FirebirdSQL#248) CI workflow updates: - linux.yml: use CMake instead of deleted Gcc.lin makefiles - msbuild.yml: add cmake -B build step to fetch Firebird headers (required by updated .vcxproj include paths) - rpi_arm64.yml: use CMake instead of deleted Gcc.lin makefiles - All workflows: trigger on new-build-system branches + PRs
c6ddc29 to
206cfd2
Compare
… feedback - Fix OdbcJdbcSetup sources: Windows uses full GUI setup (17 files), Linux uses only OdbcInstGetProp.cpp (matching makefile.sources) - Exclude ResourceManagerSink.cpp and TransactionResourceAsync.cpp from Linux build (ATL-only) - Add -D_REENTRANT -D_PTHREADS -DEXTERNAL -DunixODBC for Linux (matching old makefile.linux compile flags) - Fix ODBC linking on Linux: use ODBC::ODBC target instead of empty ODBC_LIBRARIES variable - Change IscDbc from STATIC to OBJECT library (avoids unnecessary intermediate archive; objects consumed directly by OdbcFb) - Add CMAKE_BUILD_TYPE defaulting to Release (single-config generators) - Add per-config compiler optimization flags for GCC/Clang (Debug: -O0 -g3, Release: -O3 -ftree-loop-vectorize, etc.) - Add CPU architecture detection (x86, x86_64, ARM64, generic) with -msse4.1 for x86/x86_64 (from PR FirebirdSQL#248) CI workflow updates: - linux.yml: use CMake instead of deleted Gcc.lin makefiles - msbuild.yml: add cmake -B build step to fetch Firebird headers (required by updated .vcxproj include paths) - rpi_arm64.yml: use CMake instead of deleted Gcc.lin makefiles - All workflows: trigger on new-build-system branches + PRs
|
All three existing workflows have been updated:
All workflows also trigger on the |
|
@irodushka The fixes are in! When you have a moment, please take a look and share your thoughts, suggestions, or any feedback here. |
|
@fdcastel Linux build is ok. I'm ready to merge this PR as we quickly resolve those questions. |
When Visual Studio opens CMakeLists.txt directly (Open Folder / CMake mode), it defaults to out/build/<config>/ as the binary directory. This breaks the OdbcFb.vcxproj include path (../../build/_deps/...) which expects 'build/'. CMakePresets.json standardizes the binary directory to 'build/' across all environments (command-line, Visual Studio, CLion, VS Code), so the .vcxproj include path works without manual adjustments. Also adds CMakeUserPresets.json to .gitignore for user-local overrides.
|
@irodushka The VS include path issue is now fixed — I added a All three CI workflows are green (Linux, MSBuild, RaspberryPI ARM64). Let me know if there's anything else! |
|
Well, okay! It's the final countdown! |
|
@fdcastel UPD: Well, it's really green now. And FYI: I've also updated buildno 21->22 (in WriteBuildNo.h) |
|
Continuing with the astronomical theme - this merge is one small step for a man, one giant leap for mankind! |
We’ll be changing all of this soon, too 😉 Working on the rebase for [3/3], |
This is the second of 3 planned PRs aimed at improving the project infrastructure, as outlined in the plan discussed in PR #275.
Summary
This PR adds a CMake build system for the Firebird ODBC driver and removes obsolete build configurations, vendored headers, and non-functional test projects.
The driver source code is unchanged: the CMake-built DLL is binary-compatible with the existing VS 2022 solution build.
What's new
CMake build system
CMakeLists.txt(root)FirebirdODBC.dlldriver + IscDbc static lib + test suiteIscDbc/CMakeLists.txtcmake/FetchFirebirdHeaders.cmakecmake/GetVersionFromGit.cmakecmake/Version.h.inVersion.hBuild instructions (CMake)
cmake -B build -G "Visual Studio 17 2022" -A x64 cmake --build build --config ReleaseThe test suite from PR #276 is integrated and runs via CTest:
Build instructions (VS 2022 solution)
The existing solution at
Builds/MsVc2022.win/OdbcFb.slncontinues to work but now requires a one-time CMake configure step to fetch Firebird headers:cmake -B build # fetches Firebird headers to build/_deps/Then open
Builds/MsVc2022.win/OdbcFb.slnin Visual Studio and build as usual.What's removed
Obsolete build configurations (14 directories)
All removed directories contained build files for discontinued platforms, compilers, or IDEs. Only
Builds/MsVc2022.win/is kept.Builds/Bcc55.win/Builds/CC.solaris/Builds/Gcc.darwin/Builds/Gcc.freeBSD/Builds/Gcc.lin/Builds/Gcc.solaris/Builds/MinGW_Dev-Cpp.win/Builds/MsSDK64.win/Builds/MsVc60.win/Builds/MsVc70.win/Builds/MsVc80.win/Builds/MsVc90.win/Builds/VAC.aix/Builds/aCC.HP/Also removed:
Builds/makefile.environ,Builds/makefile.sources,Builds/delDependMT.bat,makefile.in,IscDbc/makefile.in.Vendored headers
FBClient.Headers/(60 files, ~25K lines)cmake/FetchFirebirdHeaders.cmake(pinned to Firebird v5.0.2)Headers/SQL.H,Headers/SQLEXT.HHeaders/OdbcUserEvents.h(a project-specific header, not a vendored SDK file) was moved to the project root.Non-functional old test projects
JdbcTest/Test/TestInstall/The Google Test suite from PR #276 (
tests/) replaces these.Build artifacts and MinGW remnants
OdbcJdbc.exp,IscDbc/IscDbc.exp,OdbcJdbcSetup/OdbcJdbcSetup.exp— linker export files (build output, not source)OdbcJdbcMinGw.def,OdbcJdbcSetup/OdbcJdbcSetupMinGw.def— MinGW-specific definition files (MinGW build removed)OdbcJdbc.dll.manifest→ renamed toFirebirdODBC.dll.manifestto match the reference inOdbcJdbc.rcWhat's changed in existing files
OdbcConnection.h#include "Headers/OdbcUserEvents.h"→#include "OdbcUserEvents.h"Builds/MsVc2022.win/OdbcFb.vcxprojFBClient.Headerstobuild/_deps/firebird_headers-src/src/include; header reference updated for movedOdbcUserEvents.hBuilds/MsVc2022.win/OdbcFb.vcxproj.filtersOdbcUserEvents.htests/CMakeLists.txt.gitignoreWhat's NOT changed
.cpp/.hfiles, same behavior-march=native, etc.Validation
Both build systems produce a working
FirebirdODBC.dllwith identical exports (120 symbols):The VS 2022 DLL is larger due to incremental linking and debug information defaults in the solution file. The exported symbol sets are identical.
Requirements
ResourceManagerSink.cppandTransactionResourceAsync.cpp)